<!--Descriptive page name, messages and instructions-->
<h2 id='upload-heading'><%=h t('.works.import', :default => 'Import New Work') %></h2>
<%= error_messages_for :work %>
<!--/descriptions-->

<ul class="navigation">
  <% if @unposted %>
    <li id='restore-link'>
      <%= link_to 'Restore From Last Unposted Draft?', url_for(:action => :new, :load_unposted => true) %>
    </li>
  <% end %>
  <li id="form-link">
     <%= link_to( t('.standard', :default => 'Post New Work Instead?'),
       {:url => {:controller => :works, :action => :new, :import => false}},
       :href => url_for(:controller => :works, :action => :new, :import => false)) %>
  </li>
</ul>

<!-- This partial renders a form for importing a work from an existing URL -->
<div class="clear"<!--purely presentational, phase me out--></div>
<p class="message">
  <strong><%= t('.import.please_note', :default => 'Please note!') %></strong> 
  <%= t('.import_problems', :default => 'We cannot always automatically import works.') %> If you have trouble, <%= link_to t('.let_us_know', :default => "please let us know"), new_feedback_report_path %> so we can improve this tool! If your text gets truncated at the point of an em dash or accented character, try replacing these characters with HTML entities, or cutting and pasting your story into the rich text editor on the standard form.</p>
<p>You will be able to edit and complete the Archive standard header information after import is complete.</p>
<p>
  <%= t('.import.allowed_html', :default => 'Allowed HTML:') %><br />
  <code>a, abbr, acronym, address, alt, b, big, blockquote, br, caption, center, cite, class, code, col, colgroup, datetime, dd, del, dfn, div, dl, dt, em, h1, h2, h3, h4, h5, h6, height, hr, href, i, img, ins, kbd, li, name, ol, p, pre, q, samp, small, span, src, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, title, tr, tt, u, ul, var, width</code>
</p>
  
<%= form_tag url_for(:controller => :works, :action => :import) do %>
<fieldset>
  <legend><%= "Works URLs" %></legend>
  <p>
    <%= label_tag "urls", t('.import.url', :default => 'URLs for existing work(s) or for the chapters of a single work, one URL per line. (Note: if you are importing a chaptered work from ff.net, you only need to enter the first chapter. However, currently you cannot turn multiple ff.net works into the chapters of a single work.)') %> <br />
    <%= text_area_tag "urls", @urls ? @urls.join("\n") : "", :rows => 20, :cols => 90 %>
  </p>
  
  <p>
    <%= radio_button_tag "import_multiple", "works", true %>
    <%= label_tag "import_multiple_works", t('.import.works', :default => "Works (limit of %{max})", :max => current_user.archivist ? ArchiveConfig.IMPORT_MAX_WORKS_BY_ARCHIVIST : ArchiveConfig.IMPORT_MAX_WORKS) %>
    <br />
    <%= radio_button_tag "import_multiple", "chapters" %>
    <%= label_tag "import_multiple_chapters", t('.import.chapters', :default => "Chapters in a single work (limit of %{max})", :max => ArchiveConfig.IMPORT_MAX_CHAPTERS) %>
  </p>
  
  <% if current_user.archivist %>
  <p>
    <%= check_box_tag "importing_for_others" %>
    <%= label_tag "importing_for_others", t('.import.for_others', :default => "Import works for others (ONLY WITH PERMISSION)") %>
  </p>
  <% end %>

  <p>
    <%= check_box_tag "post_without_preview" %>
    <% if current_user.archivist %>
      <%= label_tag "post_without_preview", t('.import.without_preview_by_archivist', :default => "Post without previewing (STRONGLY recommended if importing for others!)") %>
    <% else %>
      <%= label_tag "post_without_preview", t('.import.without_preview', :default => "Post without previewing") %>
    <% end %>
  </p>

  <p>
    <%= check_box_tag "restricted" %>
    <%= label_tag "restricted", ts("Lock all imported stories to registered users only.") %>
  </p>

  <p>
    <%= check_box_tag "override_tags" %>
    <%= label_tag "override_tags", ts("Set the tags below on all stories, overriding whatever the importer finds. 
                  (Otherwise they will only be set if the importer cannot determine tags from the work.)") %>
  </p>

  <div id="work-form" class="work-form"><%= render :partial => 'work_tags_form', :locals => {:include_blank => true} %></div>

</fieldset>


<fieldset>
	<legend><%= "Submit" %></legend>
  <p class="submit">
  <%= submit_tag t('.import.import_story', :default => 'Import') %>
  </p>
</fieldset>

<% end %>
